Hệ thống quản lý ISP trong PHP
1 <?php
2 require_once "includes/headx.php";
3 if (!isset($_SESSION['admin_session']) )
4 {
5 $commons->redirectTo(SITE_PATH.'login.php');
6 }
7 require_once "includes/classes/admin-class.php";
8 $admins = new Admins($dbh);
9 ?>
10 <!doctype html>
11 <html lang="en" class="no-js">
12 <head>
13 <meta charset=" utf-8">
14 <meta name="viewport" content="width=device-width, initial-scale=1">
15 <link href='https://fonts.googleapis.com/css?family=Open+Sans:300,400,700' rel='stylesheet' type='text/css'>
16 <link rel="stylesheet" href="component/css/bootstrap.css"> <!-- CSS bootstrap -->
17 <link rel="stylesheet" href="component/css/style.css"> <!-- Resource style -->
18 <link rel="stylesheet" href="component/css/reset.css"> <!-- Resource style -->
19 <link rel="stylesheet" href="component/css/invoice.css"> <!-- CSS bootstrap -->
20 <script src="component/js/modernizr.js"></script> <!-- Modernizr -->
21 <title>Packages | Netway</title>
22 </head>
23 <body>
24 <div class="container">
25 <div class="row">
26 <br>
27 <button class="btn btn-success" data-toggle="modal" data-target="#add_package">Add new Packages</button>
28 <button class="btn btn-danger pull-right" onclick="window.opener.location.reload();window.close();">Close</button>
29 </div>
30 <div class="row">
31 <table class="table table-striped table-bordered">
32 <thead class="thead-inverse">
33 <tr>
34 <th>SL </th>
35 <th>Name</th>
36 <th>price</th>
37 <th>Action</th>
38 </tr>
39 </thead>
40 <tbody>
41
42 </tbody>
43 </table>
44 </div>
45 <div class="message">Do not delete packages.</div>
46 </div>
47 <!-- New modal -->
48 <div class="modal fade" id="add_package">
49 <div class="modal-dialog" role="document">
50 <div class="modal-content">
51 <div class="modal-header">
52 <button type="button" class="close" data-dismiss="modal">×</button>
53 <h4>Package details</h4>
54 </div>
55 <form id="insert_form" method="POST">
56 <div class="modal-body">
57 <fieldset>
58 <div class="form-group has-success">
59 <label for="name">Name</label>
60 <input type="text" class="form-control" id="name" name="name" placeholder="Enter Name" required>
61 </div>
62 <div class="form-group">
63 <label for="price">Price</label>
64 <input type="number" class="form-control" id="price" name="price" placeholder="Price" required>
65 </div>
66 </fieldset>
67 </div>
68 <div class="modal-footer">
69 <button type="submit" class="btn btn-primary">Submit</button>
70 <a href="#" class="btn btn-warning" data-dismiss="modal">Cancel</a>
71 </div>
72 </form>
73 </div>
74 </div>
75 </div>
76 </body>
77 <?php include 'includes/footer.php'; ?>
78 <script type="text/javascript">
79
80 $('#insert_form').on('submit',function(event){
81 event.preventDefault();
82 $.ajax({
83 url: "packages_approve.php?p=add",
84 method:"POST",
85 data:$('#insert_form').serialize(),
86 success: function (data) {
87 $('#insert_form')[0].reset();
88 $('#add_package').modal('hide');
89 viewData();
90 }
91 });
92 });
93 function viewData() {
94 $.ajax({
95 method: "GET",
96 url:"packages_approve.php",
97 success: function(data){
98 $('tbody').html(data);
99 }
100 });
101 }
102 function delData(del_id){
103 var id = del_id;
104 $.ajax({
105 method:"POST",
106 url: "packages_approve.php?p=del",
107 data: "id="+id,
108 success: function (data){
109 viewData();
110 }
111 });
112 }
113 function upData(str){
114 var name = $('#nm-'+str).val();
115 var price = $('#pr-'+str).val();
116 var id = str;
117 //console.log(name, price, id);
118 $.ajax({
119 method:"POST",
120 url: "packages_approve.php?p=edit",
121 data: "name="+name+"&price="+price+"&id="+id,
122 success: function (data){
123 $('#edit-'+str).modal('hide');
124 viewData();
125 }
126 });
127 }
128 window.onload=viewData();
129 </script>